import numpy as np

# 数据路径  现在直接放在项目目录下，方便用
train_path = ["G:/boston_house_prices/csv/train_data.csv", "csv/train_labels.csv"]
test_path = ["csv/test_data.csv", "csv/test_labels.csv"]

# path1 = "csv/train_data.csv"
# path2 = "csv/train_labels.csv"
# path3 = "csv/test_data.csv"
# path4 = "csv/test_labels.csv"

# train_data = np.loadtxt(path1,delimiter=',',usecols=np.arange(0,13),encoding='UTF-8-sig')
# train_labels = np.loadtxt(path2,delimiter=',',usecols=(0),encoding='UTF-8-sig') 
# test_data = np.loadtxt(path3,delimiter=',',usecols=np.arange(0,13),encoding='UTF-8-sig')
# test_labels = np.loadtxt(path4,delimiter=',',usecols=(0),encoding='UTF-8-sig') 

# 数据读取  直接用numpy提供的loadtxt函数进行读取csv格式的数据 
# # loadtxt函数的参数(路径, 读取csv数据的分隔符, 读取的csv的列数, 读取的格式)
train_data = np.loadtxt(train_path[0],delimiter=',',usecols=np.arange(0,13),encoding='UTF-8-sig')
train_labels = np.loadtxt(train_path[1],delimiter=',',usecols=(0),encoding='UTF-8-sig') 
test_data = np.loadtxt(test_path[0],delimiter=',',usecols=np.arange(0,13),encoding='UTF-8-sig')
test_labels = np.loadtxt(test_path[1],delimiter=',',usecols=(0),encoding='UTF-8-sig') 

print(train_data)